BigDFT.Interop.BabelInterop module

This module contains some wrappers for using OpenBabel to perform various operations on BigDFT molecules.

https://open-babel.readthedocs.io/en/latest/UseTheLibrary/Python.html

compute_fingerprint(sys, fps='fp2')[source]

Computes the fingerprint for a particular fragment.

Parameters
  • sys (BigDFT.Systems.System) – the fragment to compute the representation of.

  • fps (str) – the type of finger print to compute.

Returns

a fingerprint for this fragment.

Return type

(openbabel.OBFingerprint)

compute_smiles(sys)[source]

Computes the SMILES representation of a given system.

Parameters

sys (BigDFT.System.Systems) – the system to compute the representation of.

Returns

the smiles representation of this molecule.

Return type

(str)

compute_system_forces(sys, forcefield='MMFF94', verbose=False)[source]

Assign the forces of a system using an openbabel forcefield.

Parameters
  • sys (BigDFT.Systems.System) – the system to compute.

  • forcefield (str) – the type of forcefield to use.

  • verbose (bool) – whether to have openbabel run in verbose mode.

Returns

the energy of the system.

Return type

(float)

convert_babel_to_system(mol)[source]

Convert a BigDFT fragment to an open babel molecule.

Parameters

mol (openbabel.OBMol) – the molecule to convert.

Returns

bigdft system.

Return type

(BigDFT.Systems.System)

convert_system_to_babel(sys)[source]

Convert a BigDFT system to an open babel molecule.

Parameters

sys (BigDFT.Systems.System) – the system to convert.

Returns

an open babel type molecule.

Return type

(openbabel.OBMol)

molecular_dynamics(sys, steps, temperature, forcefield='MMFF94', timestep=0.001, verbose=False)[source]

Run molecular dynamics on a given fragment..

Parameters
  • sys (BigDFT.Systemtems.System) – the system to run.

  • steps (int) – the number of MD steps to take.

  • temperature (float) – temperature in K.

  • timestep (float) – time step in picoseconds.

  • forcefield (str) – the type of forcefield to use.

  • constraints (list) – for each atom, list whether it if frozen or not.

  • verbose (bool) – if True, the openbabel output will be printed.

Returns

a new system with the optimized positions.

Return type

(BigDFT.Systems.System)

optimize_system(sys, forcefield='MMFF94', method='SteepestDescent', steps=1000, econv=1e-06, verbose=False)[source]

Optimize the geometry of a given fragment.

Parameters
  • sys (BigDFT.Systems.System) – the fragment to optimize.

  • forcefield (str) – the type of forcefield to use.

  • verbose (bool) – if True, the openbabel output will be printed.

Returns

a new fragment with the optimized positions.

Return type

(BigDFT.Fragments.Fragment)

system_energy(sys, forcefield='MMFF94', verbose=False)[source]

Compute the energy of a system using an openbabel forcefield.

Parameters
  • sys (BigDFT.Systems.System) – the system to compute.

  • forcefield (str) – the type of forcefield to use.

  • verbose (bool) – whether to have openbabel run in verbose mode.

Returns

the energy value computed in Hartree.

Return type

(float)

BigDFT.Interop.BabelInterop example

Below we show an example of using the OpenBabel interoperability functions.

def _example():
    """Example of using OpenBabel interoperability"""
    from BigDFT.Systems import System
    from BigDFT.Fragments import Fragment
    from BigDFT.IO import XYZReader
    from os.path import join

    # Read in a system.
    sys = System()
    sys["FRA:1"] = Fragment()
    with XYZReader("CH4") as ifile:
        for at in ifile:
            sys["FRA:1"] += Fragment([at])

    # We can compute the smiles representation.
    print(compute_smiles(sys))

    # The energy.
    print(system_energy(sys, forcefield="UFF"))

    # Extract the forces.
    compute_system_forces(sys, forcefield="UFF")
    for frag in sys.values():
        for at in frag:
            print(at["force"])

    # Optimize the geometry.
    sys2 = optimize_system(sys, forcefield="UFF")
    print(system_energy(sys2, forcefield="UFF"))